//class Circle implements Cloneable {
//    Point p;
//    int r;
//
//    public Circle(Point p, int r) {
//        this.p = p;
//        this.r = r;
//    }
//
//    @Override
//    protected Circle clone() {
//        Circle c = null;
//        try {
//            c = (Circle) super.clone();
//            c.p = this.p.clone();
//        } catch (CloneNotSupportedException e) {
//            e.printStackTrace();
//        }
//        return c;
//    }
//}
//
//class Point implements Cloneable {
//    int x;
//    int y;
//
//    public Point(int x, int y) {
//        this.x = x;
//        this.y = y;
//    }
//
//    @Override
//    protected Point clone() {
//        try {
//            return (Point) super.clone();
//        } catch (CloneNotSupportedException e) {
//            e.printStackTrace();
//        }
//        return null;
//    }
//}
//
//public class Test {
//    public static void main(String[] args) {
//        Point p = new Point(1, 1);
//        Circle c = new Circle(p, 1);
//        Circle c2 = c.clone();
//
//        // 修改原对象的属性
//        c.p.x = 2;
//        c.r = 2;
//
//        // 打印原对象和克隆对象的属性
//        System.out.println("原对象：");
//        System.out.println("Center: (" + c.p.x + ", " + c.p.y + ")");
//        System.out.println("Radius: " + c.r);
//
//        System.out.println("克隆对象：");
//        System.out.println("Center: (" + c2.p.x + ", " + c2.p.y + ")");
//        System.out.println("Radius: " + c2.r);
//    }
//}


public class EXA10_2 extends Thread {
    public int n = 0;

    public void run() {
        long time = (long) (Math.random() * 200);
        System.out.println("time:" + time);

        while (true) {
            System.out.println(Thread.currentThread().getName() + "：" + (n++));
            try {
                Thread.sleep(time);
            } catch (Exception e) {
                e.printStackTrace();
            }
            if (n == 10)
                System.exit(0);
        }
    }

    public static void main(String[] args) {
        Thread t1 = new EXA10_2() {
            public void run() {
                while (true) {
                    System.out.println("安工大");
                    try {
                        Thread.sleep(1000);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            }
        };
        t1.setName("线程1");
        t1.start();

        Thread t2 = new EXA10_2() {
            public void run() {
                while (true) {
                    try {
                        Thread.sleep(2000);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                    System.out.println("计算机");
                }
            }
        };
        t2.setName("线程2");
        t2.start();
    }
}
